<!DOCTYPE html>
<html lang="en">
<head>
    <include file="Public/public_head" title="{$article['current']['title']}-"
             keywords="{$article['current']['keywords']}" description="{$article['current']['description']}"/>
    <css file="__PUBLIC__/static/ueditor1_4_3/third-party/SyntaxHighlighter/shCoreDefault.css"/>
    <link rel="canonical" href="{:U('Home/Index/article',array('aid'=>$_GET['aid']),'',true)}"/>
</head>
<body>
<include file="Public/public_nav"/>
<div class="b-h-70"></div>

<section class="content-wrap">
    <div id="b-content" class="container">
        <div class="row">
            <main class="col-lg-10 col-lg-push-1 main-content">
                <article class="post">
                    <if condition="$user['is_admin'] eq 1">
                    <div class="pull-right">

 	                    <span  style="width: 120px;display:inline-block;" >
									<ul class="nav">
                                        <li class="dropdown" id="accountmenu">
                                            <a class="dropdown-toggle" data-toggle="dropdown" href="#"><i style="color:#999" class="fa fa-cog"></i></a>
                                            <ul class="dropdown-menu">

                                                <li ><a href="{:U('Home/index/edit',array('aid'=>$article['current']['aid']))}">修改</a></li>
                                                <li><a href="javascript:;" onclick="addProject()">添加公益项目</a></li>
                                                <li><a href="#" data-toggle="modal" data-target="#b-modal-grade" >设置年级人数</a></li>
                                                <if condition="$article['current']['status'] neq 1">
                                                     <li><a href="#" onclick="changestatus({$article['current']['aid']},1)" >面临搬迁</a></li>
                                                </if>
                                                <if condition="$article['current']['status'] neq 2">
                                                      <li><a href="#" onclick="changestatus({$article['current']['aid']},2)" >已停办</a></li>
                                                </if>
                                                <if condition="$article['current']['status'] neq 0">
                                                    <li><a href="#" onclick="changestatus({$article['current']['aid']},0)" >恢复运营</a></li>
                                                </if>
                                            </ul>
                                        </li>
                                    </ul>
								</span>

                    </div>

                    </if>
                    <div class="post-head">
                        <h1 class="post-title">{$article['current']['title']}&nbsp;&nbsp;
                            <if condition="$article['current']['status'] eq 0">
                                <a href="javascript:;" id="tips1"  rel="popover" data-content="正常运营"> <i class="fa fa-lightbulb-o" style="color:#33ff00"></i></a>
                            <else/>
                                    <if condition="$article['current']['status'] eq 1">
                                        <a href="javascript:;" id="tips1"  rel="popover" data-content="面临搬迁"> <i class="fa fa-lightbulb-o" style="color:orange"></i></a>
                                    <else/>
                                        <a href="javascript:;" id="tips1"  rel="popover" data-content="已停办"> <i class="fa fa-lightbulb-o" style="color:red"></i></a>
                                    </if>
                            </if>
                            <if condition="$article['current']['is_show'] eq 0">
                                <i class="fa fa-file" style="color:orange"></i>
                            </if>
                        </h1>


                    </div>
                    <div class="post-content">
                    <div class="form-group">
                        <div class="col-md-12">
                        <section label="Copyright Reserved by PLAYHUDONG." style="margin: 5px 0px 0px; padding: 16px;margin:1em 0; border-style: none; line-height: 25px; border: 1px solid #ccc;border-radius: 4px;box-shadow:0px 2px 8px rgb(153, 153, 153)" id="shifu_c_034" donone="shifuMouseDownCard(&#39;shifu_c_034&#39;)">
                        <img  src="{$article['current']['pic_path']}" alt="" style="width:100%;">
                         </section>
                    </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-4">
                            <section label="Copyright Reserved by PLAYHUDONG." style="height:250px;margin: 5px 0px 0px; padding: 16px;margin:1em 0; border-style: none; line-height: 25px; border: 1px solid #ccc;border-radius: 4px;box-shadow:0px 2px 8px rgb(153, 153, 153)" id="shifu_c_034" donone="shifuMouseDownCard(&#39;shifu_c_034&#39;)">


                                <p>学段：
                                    <volist name="article['current']['tag']" id="tag">
                                        {$tag['tname']}&nbsp;
                                    </volist>
                                </p>
                                <p>建校年份：{$article['current']['beginyear']}</p>
                                <p>所在地区：{$article['current']['area']}</p>
                                <p>详细地址：{$article['current']['address']}</p>
                                <p>是否注册：<if condition="$article['current']['verify'] eq 1">是<else/>否</if></p>

                            </section>

                        </div>
                        <div class="col-md-4">
                            <section label="Copyright Reserved by PLAYHUDONG." style="height:250px;margin: 5px 0px 0px; padding: 16px;margin:1em 0; border-style: none; line-height: 25px; border: 1px solid #ccc;border-radius: 4px;box-shadow:0px 2px 8px rgb(153, 153, 153)" id="shifu_c_034" donone="shifuMouseDownCard(&#39;shifu_c_034&#39;)">
                                <p>占地面积：{$article['current']['acreage']}平方米</p>
                                <p>教师人数：{$article['current']['teacher']}&nbsp;人</p>
                                <p><a href="#" data-toggle="modal" data-target="#grade_num" style="color: #0000cc">学生人数：{$article['current']['student']}&nbsp;人</a></p>

                                <p>薪资水平：{$article['current']['salary']}&nbsp;元</p>

                                <p>学费水平：{$article['current']['price']}&nbsp;元</p>
                                </section>
                        </div>
                        <div class="col-md-4" >
                            <section label="Copyright Reserved by PLAYHUDONG."   style="height:250px;margin: 5px 0px 0px; padding: 5px;margin:1em 0; border-style: none; line-height: 25px; border: 1px solid #ccc;border-radius: 4px;box-shadow:0px 2px 8px rgb(153, 153, 153)" id="location" donone="shifuMouseDownCard(&#39;shifu_c_034&#39;)">
                                <div id="iMap" style="width:100%;height: 240px;"></div>
                            </section>
                        </div>
                    </div>

                    <notempty name="Think.session.user">
                        <notempty name="article.current.contact">
                            <div class="form-group">
                                <div class="col-md-12">
                                    <section label="Copyright Reserved by PLAYHUDONG."   style="margin: 5px 0px 0px; padding: 5px;margin:1em 0; border-style: none; line-height: 25px; border: 1px solid #ccc;border-radius: 4px;box-shadow:0px 2px 8px rgb(153, 153, 153)" id="location" donone="shifuMouseDownCard(&#39;shifu_c_034&#39;)">
                                     <table>
                                        <tr><td>联系人</td><td>职位</td><td>手机</td><td>邮箱</td><td>微信</td></tr>
                                       <volist name="article.current.contact" id="vo">
                                          <tr> <td>{$vo['c_name']}</td><td>{$vo['role1']}</td><td>{$vo['tel']}</td><td>{$vo['email']}</td><td>{$vo['wechat']}</td></tr>
                                       </volist>
                                        </table>
                                    </section>
                                </div>
                            </div>
                        </notempty>
                    </notempty>
                    <notempty name="article.current.content1">
                    <div class="form-group">
                       <div class="col-md-12" >
                           <section label="Copyright Reserved by PLAYHUDONG."   style="margin: 5px 0px 0px; padding: 5px;margin:1em 0; border-style: none; line-height: 25px; border: 1px solid #ccc;border-radius: 4px;box-shadow:0px 2px 8px rgb(153, 153, 153)" id="location" donone="shifuMouseDownCard(&#39;shifu_c_034&#39;)">
                           <div class="content">{$article['current']['content1']}</div>
                           </section>
                       </div>
                    </div>
                    </notempty>

                    <notempty name="article.current.project">
                        <div class="form-group">
                            <div class="col-md-12">
                                <section label="Copyright Reserved by PLAYHUDONG."   style="margin: 5px 0px 0px; padding: 5px;margin:1em 0; border-style: none; line-height: 25px; border: 1px solid #ccc;border-radius: 4px;box-shadow:0px 2px 8px rgb(153, 153, 153)" id="location" donone="shifuMouseDownCard(&#39;shifu_c_034&#39;)">
                                   <table>
                                      <tr><td>公益项目</td><td>机构</td><td>起止时间</td>  <if condition="$user['is_admin'] eq 1"><td>操作</td></if></tr>
                                    <volist name="article.current.project" id="vo" key="k">
                                        <tr>
                                            <td>
                                                <?php if(!empty($vo['description'])||$vo['father']!=0){?>
                                                    <a href="javascript:;" id="tips{$k+2}"  rel="popover" data-content="{$vo['description']}<?php if($vo['father']>0){?>&nbsp;&nbsp;该项目是{$vo['father-alt']}的子项目<?php } ?>" style="color:#000000">
                                                <?php } ?>
                                                    {$vo['p_name']}</a>
                                                <if condition="$user['is_admin'] eq 1"><a href="#" data-toggle="modal" data-target="#commenting-{$vo['pid']}" style="color: #0000cc">&nbsp;&nbsp;<i class="fa fa-commenting-o" style="font-style: normal">{$vo['comments_num']}</i></a></if>
                                            </td>
                                            <td>{$vo['o_name']}</td>
                                            <td>{$vo['time']}</td>
                                            <if condition="$user['is_admin'] eq 1">
                                            <td>
                                                <a href="javascript:;" style="color:blue" onclick="delproject({$vo['id']})">删除</a>
                                            </td>
                                            </if>
                                        </tr>
                                    </volist>
                                   </table>
                                </section>
                            </div>
                        </div>
                    </notempty>

                        <notempty name="article.current.user">
                            <div class="form-group">
                                <div class="col-md-12">
                                    <section label="Copyright Reserved by PLAYHUDONG."   style="margin: 5px 0px 0px; padding: 5px;margin:1em 0; border-style: none; line-height: 25px; border: 1px solid #ccc;border-radius: 4px;box-shadow:0px 2px 8px rgb(153, 153, 153)" id="location" donone="shifuMouseDownCard(&#39;shifu_c_034&#39;)">

                                            <volist name="article.current.user" id="vo">
                                                <div class="form-group">{$vo['username']}于{$vo['create_time1']}{$vo['type1']}</div>
                                            </volist>

                                    </section>
                                </div>
                            </div>
                        </notempty>


                    </div>
                </article>

            </main>
            <!--<aside class="col-md-4 sidebar">-->
            <!--<div class="widget">-->
            <!--<h4 class="title">标签云</h4>-->
            <!--<div class="content tag-cloud">-->
            <!--<volist name="tags" id="tag">-->
            <!--<a href="{:U('Index/index',array('tag'=>$tag['tag_name']))}">{$tag['tag_name']}</a>-->
            <!--</volist>-->
            <!--</div>-->
            <!--</div>-->
            <!--</aside>-->


        </div>

        <if condition="$user['is_admin'] eq 1">
                <include file="Public/public_comment"/>

        </if>
    </div>
</section>

<div class="modal fade" id="b-modal-project" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"   aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <center><h4 class="modal-title">添加公益项目</h4></center>
            </div>
            <div class="form-horizontal">
                <div class="modal-body">
                        <form id="addproject">
                            <div class="form-group" id="projectid">
                                <div class="col-md-offset-1 col-md-2" >选择项目</div>
                                <div class="col-md-4">
                                   <select id="pid" name="pid" class="form-control">
                                       <option value="">请选择</option>
                                       <volist name="projects" id="vo">
                                           <option value="{$vo['pid']}">{$vo['p_name']} </option>
                                       </volist>
                                   </select>
                                </div>
                                <div class="col-md-1"><a href="javasript:;" id="newproject">新增</a></div>
                            </div>


                            <div id="new_project" style="display:none">
                            <div class="form-group" >
                                <div class="col-md-offset-1 col-md-2" >新增项目</div>
                                <div class="col-md-4" ><input type="text" class="form-control" id="p_name" name="p_name" placeholder="项目名称"></div>

                            </div>
                            <div class="form-group">
                                <div class="col-md-offset-1 col-md-2" ></div>
                                <c id="orgid">
                                <div class="col-md-3">
                                    <select id="oid" name="oid" class="form-control" onchange="plist(this.options[this.options.selectedIndex].value)">
                                        <option value="">选择机构</option>
                                        <volist name="orgs" id="vo">
                                            <option value="{$vo['oid']}" >{$vo['o_name']} </option>
                                        </volist>
                                    </select>
                                </div>
                                <div class="col-md-1"><a href="javasript:;" id="neworg">新增</a></div>
                                </c>
                                <div class="col-md-4" id="new_org" style="display:none" ><input type="text" class="form-control" id="o_name" name="o_name" placeholder="机构名称"></div>
                            </div>
                                <c id="fatherlist"></c>

                            <div class="form-group" >
                                <div class="col-md-offset-1 col-md-2" ></div>
                                <div class="col-md-8" ><input type="text" class="form-control" id="description" name="description" placeholder="描述(30字以内)"></div>

                            </div>

                            </div>
                            <div class="form-group">
                                <div class="col-md-offset-1 col-md-2" >起止时间 </div>
                                <div class="col-md-4"><input id='b_time' name='b_time' type="text" value="" readonly class="form-control form_datetime" placeholder='起始时间'></div>
                                <div class="col-md-4"><input id='f_time' name='f_time'   type="text" value="" readonly class="form-control form_datetime" placeholder='结束时间'></div>
                            </div>

                            <div class="form-group">
                                <div class="col-md-offset-5 col-md-2">
                                    <input name="aid" id="aid" type="hidden" value="{$article['current']['aid']}">
                                    <button class="btn btn-primary" type="submit">提交</button>
                                </div>
                            </div>
                        </form>

                </div>
            </div>
        </div>
    </div>
</div>




<div class="modal fade" id="b-modal-grade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"   aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <center><h4 class="modal-title">设置年级人数</h4></center>
            </div>
            <div class="form-horizontal">
                <div class="modal-body">
                    <form id="addgrade">

                            <div id='gradebox'>
                                <notempty name="article.current.grade">
                                    <volist name="article.current.grade" id="vo" key="k1">
                                        <div class="form-group">
                                            <div class="col-md-offset-2 col-md-3">
                                                <select name="grade[]"  class="form-control">
                                                    <option value=''>年级</option>
                                                    <volist name='option.grade_option' id='v' key="k">
                                                        <option value='{$k}' <if condition="$vo['grade1'] eq $v">selected</if>>{$v}</option>
                                                    </volist>
                                                </select>
                                            </div>
                                            <div class="col-md-3">
                                                <input type="text" name="g_num[]" class="form-control" value="{$vo['g_num']}" placeholder="人数">
                                            </div>

                                            <div class="col-md-3">


                                                <i class="fa fa-minus" onclick="$(this).parent().parent().remove();return false;"></i>
                                                <if condition="$k1 eq 1">&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:;"  id = "add" ><i class="fa fa-plus"></i></a></if>
                                            </div>
                                        </div>
                                    </volist>
                                <else/>
                                    <div class="form-group">
                                        <div class="col-md-offset-1 col-md-3">
                                            <select name="grade[]"  class="form-control">
                                                <option value=''>年级</option>
                                                <volist name='option.grade_option' id='v' key="k">
                                                    <option value='{$k}'>{$v}</option>
                                                </volist>
                                            </select>
                                        </div>
                                        <div class="col-md-3">
                                            <input type="text" name="g_num[]" class="form-control" value="" placeholder="人数">
                                        </div>

                                        <div class="col-md-3">


                                            <i class="fa fa-minus" onclick="$(this).parent().parent().remove();return false;"></i>&nbsp;&nbsp;&nbsp;&nbsp;
                                            <a href="javascript:;"  id = "add" ><i class="fa fa-plus"></i></a>
                                        </div>
                                    </div>
                                </notempty>

                            </div>

                        <div class="form-group">
                            <div class="col-md-offset-5 col-md-2">
                                <input name="aid" type="hidden" value="{$article['current']['aid']}">
                                <button class="btn btn-primary" type="submit">提交</button>
                            </div>
                        </div>

                </form>
            </div>
        </div>
    </div>
</div>
</div>


<div class="modal fade" id="grade_num" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"   aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <center><h4 class="modal-title">年级学生人数</h4></center>
            </div>
            <div class="form-horizontal">
                <div class="modal-body">
                    <div id="g_num">
                    <notempty name="article.current.grade">
                        <volist name="article.current.grade" id="vo">
                           <div class="form-group" style="text-align: center">

                                {$vo['grade1']}&nbsp;&nbsp; {$vo['g_num']}

                           </div>


                        </volist>
                        <else/>
                        <p>暂无年级人数数据</p>

                    </notempty>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<volist name="article.current.project" id="vo">

<div class="modal fade" id="commenting-{$vo['pid']}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"   aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <center><h4 class="modal-title">项目评论</h4></center>
            </div>
            <div class="form-horizontal">
                <div class="modal-body">
                    <notempty name="Think.session.user">

                        <form class="project_comment">
                            <div><textarea style="width:100% " id="content-{$vo['pid']}"></textarea></div>
                            <input type="hidden" name="comment_pid" value="{$vo['pid']}">
                            <div class="row top-tags"> <div  style="text-align: center"> <input type="submit" class="tag-element" value="提交"> </div></div>
                        </form>
                    </notempty>
                        <notempty name="vo.comments">
                            <div id="comments-{$vo['pid']}">
                                <volist name="vo.comments" id="v">
                                    <div class="form-group" >
                                        <div class="col-xs-2 col-sm-1 col-md-1 col-lg-1 b-pic-col">
                                            <img class="talk-avatar small" src="{:avatar($v['uid'])}">
                                        </div>
                                        <div class="col-xs-10 col-sm-11 col-md-11 col-lg-11 b-content-col b-cc-first"><p class="b-content"><span
                                                class="b-user-name">{:get_username($v['uid'])}</span>：{$v['content']}</p>

                                            <p class="b-date">
                                                <span> {:friendly_date($v['date'])}</span>
                                            </p>
                                        </div>
                                    </div>
                                </volist>
                            </div>
                        <else/>
                            <p>暂无评语</p>
                        </notempty>

                </div>
            </div>
        </div>
    </div>
</div>
</volist>

<include file="Public/public_login"/>
<include file="Public/public_foot"/>
<js file="__PUBLIC__/static/ueditor1_4_3/third-party/SyntaxHighlighter/shCore.js"/>
<js file="__PUBLIC__/static/layer-2.4/layer.js"/>
<script type="text/javascript">

    var mapObj;
    var lnglatXY;
    //初始化地图
    function mapInit(){
        var opt = {
            level: 10, //设置地图缩放级别
            center: new AMap.LngLat({$lnglat}) //设置地图中心点
        }
        mapObj = new AMap.Map("iMap", opt);

        AMap.event.addListener(mapObj,'click',getLnglat); //点击事件

        addMarker()
    }
    function geocoder() {
        var MGeocoder;
        //加载地理编码插件
        mapObj.plugin(["AMap.Geocoder"], function() {
            MGeocoder = new AMap.Geocoder({
                radius: 1000,
                extensions: "all"
            });
            //返回地理编码结果
            AMap.event.addListener(MGeocoder, "complete", geocoder_CallBack);
            //逆地理编码
            MGeocoder.getAddress(lnglatXY);
        });
        //加点
        var marker = new AMap.Marker({
            map:mapObj,
            icon:"http://webapi.amap.com/images/0.png",
            position: lnglatXY,
            offset: new AMap.Pixel(-5,-30)
        });
        // mapObj.setFitView();
    }
    //回调函数
    function geocoder_CallBack(data) {
        var address;
        //返回地址描述
        address = data.regeocode.formattedAddress;
        //返回结果拼接输出
        //document.getElementById("iAddress").innerHTML = address;
    }
    //鼠标点击，获取经纬度坐标
    function getLnglat(e){
        mapObj.clearMap();
        var x = e.lnglat.getLng();
        var y = e.lnglat.getLat();
        document.getElementById("lnglat").value = x + "," + y;

        lnglatXY = new AMap.LngLat(x,y);
        geocoder();
    }

    //实例化marker
    function addMarker(){
        marker=new AMap.Marker({
            icon:"http://webapi.amap.com/images/0.png",
            position:new AMap.LngLat({$lnglat}),
        });

        marker.setMap(mapObj);  //在地图上添加点
    }

    function addMarker2(){
        mapObj.clearMap();
        marker2 = new AMap.Marker({
            position:(new AMap.LngLat({$lnglat})),
            draggable:true,  //点标记可拖拽
            cursor:'move',
            raiseOnDrag:true //鼠标拖拽点标记时开启点标记离开地图的效果
        });
        marker2.setMap(mapObj);
    }
    function marker2Cartoon(){
        marker2.setAnimation('AMAP_ANIMATION_BOUNCE'); //设置点标记的动画效果，此处为弹跳效果
    }



    SyntaxHighlighter.all();
    ajaxCommentUrl = "{:U('Home/Index/ajax_comment','','',true)}";
    check_login = "{:U('Home/User/check_login','','',true)}";
</script>
<js file="__HOME_JS__/comment.js"/>
<script>
    window.onload=mapInit;


    $(".form_datetime").datetimepicker({
        format: 'yyyy-mm-dd',
        language:  'zh-CN',
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        minView:2,
        showMeridian: 0
    });

    function plist(oid){

        $.ajax({
            type: "POST",
            dataType: "json",
            url: "{:U('home/index/addfather')}",
            data: {oid: oid},
            success: function(data){
                if (data.status == 0) {
                    bootbox.alert(data.info);
                    return  false;
                } else {
                    $('#fatherlist').html(data);
                }

            }
        });
    }

    function delproject(id){

        if(confirm("确认要删除这个项目吗?")) {
            $.ajax({
                type: "POST",
                dataType: "json",
                url: "{:U('home/index/delproject')}",
                data: {id: id},
                success: function (data) {
                    if (data.status == 0) {
                        bootbox.alert(data.info);
                        return false;
                    } else {
                        location.reload();
                    }

                }
            });
        }
    }


    function delreply(cid){

        if(confirm("确认要删除这条评论吗?")) {
            $.ajax({
                type: "POST",
                dataType: "json",
                url: "{:U('home/index/delreply')}",
                data: {cid: cid},
                success: function (data) {
                    if (data.status == 0) {
                        bootbox.alert(data.info);
                        return false;
                    } else {
                        location.reload();
                    }

                }
            });
        }
    }

    //显示遮罩层
    function showMask(){
        $("#mask").css("height",$(document).height());
        $("#mask").css("width",$(document).width());
        $("#mask").show();
    }
    //隐藏遮罩层
    function hideMask(){

        $("#mask").hide();
    }

    function changestatus(aid,status){
        var operate='';
        switch (status){
            case 0:
            operate= '恢复运营' ;
        }
        switch (status){
            case 1:
                operate= '面临搬迁' ;
        }
        switch (status){
            case 2:
                operate= '已停办' ;
        }
        if(confirm("确认这个学校"+operate+"吗?")) {
            $.ajax({
                type: "POST",
                dataType: "json",
                url: "{:U('home/index/changestatus')}",
                data: {aid:aid,status:status},
                success: function (data) {
                    if (data.status == 0) {
                        bootbox.alert(data.info);
                        return false;
                    } else {
                        location.reload();
                    }

                }
            });
        }
    }

    $(function(){

        $("#reply").on('submit', function(e) {
            e.preventDefault();
            var aid  = $('#aid').val();
            var content = $.trim($('#comment').val());
            if (content == '') {
                bootbox.alert('内容不能为空');
                return false;
            }
            showMask();
            $.ajax({
                url: "{:U('index/reply')}",
                type: 'POST',
                dataType: 'json',
                data: {aid: aid, content: content},

                success :function(data) {
                    hideMask();
                    if (data.status ==0) {
                        bootbox.alert(data.info);
                        return false;
                    } else {
                        location.reload();
                    }

                }
            });
        });

        $('#addproject').on('submit', function(e) {
            e.preventDefault();

            var pid = $('#pid').val();
            var oid = $('#oid').val();
            var p_name = $.trim($('#p_name').val());
            var o_name = $.trim($('#o_name').val());
            var description = $.trim($('#description').val());
            var b_time = $('#b_time').val();
            var f_time = $('#f_time').val();

            if (pid == '') {
                if(p_name ==''){
                    bootbox.alert('项目不能为空！');
                    return false;
                }
                if (oid == ''&& o_name =='') {
                    bootbox.alert('机构不能为空！');
                    return false;
                }
            }

            if(b_time == ''){
                bootbox.alert('起始时间不能为空！');
                return false;
            }

            if(f_time == ''){
                bootbox.alert('结束时间不能为空！');
                return false;
            }

            $.ajax({
                type: "POST",
                dataType: "json",
                url: "{:U('home/index/addproject')}",
                data: $("#addproject").serialize(),
                success: function(data){
                    if (data.status == 0) {
                        bootbox.alert(data.info);
                        return  false;
                    } else {
                        location.reload();
                    }
                }
            });
        });



        $('#addgrade').on('submit', function(e) {
            e.preventDefault();

            $.ajax({
                type: "POST",
                dataType: "json",
                url: "{:U('home/index/addgrade')}",
                data: $("#addgrade").serialize(),
                success: function(data){
                    if (data.status == 0) {
                        bootbox.alert(data.info);
                        return  false;
                    } else {
                        $('g_num').html(data);
                        $('#b-modal-grade').modal("hide");
                        $('#grade_num').modal("show");
                    }

                }
            });
        });




        $('.project_comment').on('submit', function(e) {
            e.preventDefault();
            var aid=$("*[name='comment_pid']").val();
            var content=$("#content-"+aid).val();
            var sid=$("#aid").val();

            if(content==''){
                bootbox.alert('评语不能为空！');
                return false;
            }

            $.ajax({
                type: "POST",
                dataType: "json",
                url: "{:U('home/index/post_comment')}",
                data: {aid:aid,content:content,pid:0,sid:sid},
                success: function(data){
                    if (data.status == 0) {
                        bootbox.alert(data.info);
                        return  false;
                    } else {
                        $( "#comments-"+aid).before(data);
                        $( '#content-'+aid).val('');

                    }

                }
            });
        });

    });


    $("#add").click(function(){

        var div = '<div class="form-group">';
        div=div+'<div class="col-md-offset-2 col-md-3"> <select name="grade[]"  class="form-control"><option value="">年级</option><volist name="option.grade_option" id="v" key="k"><option value="{$k}">{$v}</option></volist></select></div>';
        div=div+'<div class="col-md-3"><input type="text" name="g_num[]" class="form-control" placeholder="人数"></div>';
        div=div+'<div class="col-md-3"><i class="fa fa-minus" onclick="$(this).parent().parent().remove();return false;"></i></div></div>';

        $("#gradebox").append(div);//向form中追加div
        j+=1;
    });

    $("#del").click(function(){
        $(this).parent().parent().remove();
    });


</script>
</body>
</html>